<?php

namespace models;

class Menu {

	/** 根据菜获取相关的菜单 **/
	public static function getByStaff($db, $staff) {
        $sql = "SELECT id, title, thumbnail, viewCount, praiseCount FROM t_menu WHERE isDeleted = 0 AND (main like \"%". $staff ."%\" OR title like \"%". $staff ."%\") ";
	    $data = $db->fetchAll($sql);
	    return $data;
    }

    /***增加点赞量*/
    public static function incPraise($db, $mid) {
    	$sql = "UPDATE t_menu SET praiseCount=praiseCount+1 WHERE id=$mid";
		$data = $db->executeUpdate($sql);
		return $data;
    }

    /***减少点赞量*/
    public static function descPraise($db, $mid) {
    	$sql = "UPDATE t_menu SET praiseCount=praiseCount-1 WHERE id=$mid";
		$data = $db->executeUpdate($sql);
		return $data;
    }
}

